This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Jun 29, 2011, 11:00 PM
35 Posts
topic has been resolvedResolved

dijit.ProgressBar and dijit.Dialog

  • Category: Dojo and Client Side JavaScript
  • Platform: All
  • Release: 8.5.3
  • Role:
  • Tags:
  • Replies: 2
Hi,
I have a button on my xPage that is executing a backend agent.  I have loaded the dijit.progressbar and dijit.dialog modules.  The onclick event CSJS is the following:

// Split up bar into 5% segments
numParts = Math.floor(100/5);
jsProgress.update({ maximum: numParts, progress:0 });
for (var i=0; i<=numParts; i++){
// This plays update({progress:0}) at 1nn milliseconds,
// update({progress:1}) at 2nn milliseconds, etc.
setTimeout("jsProgress.update({ progress: " + i + " })",(i+1)*100 + 
Math.floor(Math.random()*100));
 
And the SSJS calls the agent.  
My problem is my background agent isn't firing with the button as a partial refresh.  I'm getting the
"Problem submitting an area of the page..." error. 
 
So I'm doing a full refresh which fires my agent but I can't get my progressbar to work.  
Any ideas? 
Jun 30, 2011, 12:42 PM
261 Posts
Re: dijit.ProgressBar and dijit.Dialog
Hello Stacey,
 
Doing a partial refresh to show a dialog with a partial bar and running an agent should work. I did use the same construction. Below is a simple sample XPage that shows how I did it.
 
Note that I've set the indeterminate property of the progress bar to true, since I cannot give feedback to the user what progress the agent has made. I only know that it is running until the refresh is complete. When the agent is finished, the code in the onComplete event is called to hide the progress dialog.

Good luck,
Mark


<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" dojoTheme="true">

    <xp:this.resources>
        <xp:dojoModule name="dijit.Dialog"></xp:dojoModule>
        <xp:dojoModule name="dijit.ProgressBar"></xp:dojoModule>
    </xp:this.resources>
   
    <xp:button value="Start server agent" id="button1">
        <xp:eventHandler event="onclick" submit="true"
            refreshMode="partial" refreshId="computedField1">
            <xp:this.script><![CDATA[var progressBar = new dijit.ProgressBar({indeterminate:true, layoutAlign: "left"});

progressDlg = new dijit.Dialog( {
    title:"Please wait...", 
    content: progressBar,
     style: "width: 150px"
     });
progressDlg.show();]]></xp:this.script>
            <xp:this.onComplete><![CDATA[progressDlg.hide();]]></xp:this.onComplete>

            <xp:this.action><![CDATA[#{javascript:var agent = database.getAgent("MyAgent");
agent.run();}]]></xp:this.action>
        </xp:eventHandler>
    </xp:button>
   
    <br /><br />
    Current (server) time in milliseconds (will be refreshed/ updated when agent is finished):&#160;
    <xp:text escape="true" id="computedField1"
        value="#{javascript:new Date().getTime();}">
        <xp:this.converter>
            <xp:convertNumber type="number" integerOnly="true"></xp:convertNumber>
        </xp:this.converter>
    </xp:text>

</xp:view>
Jul 5, 2011, 10:11 PM
35 Posts
Re: dijit.ProgressBar and dijit.Dialog
 Works Great!! Thanks so much!!

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal